//
//  LCBibleTableViewCell.m
//  自适应TableView布局
//
//  Created by jiukuyinyue on 2017/10/12.
//  Copyright © 2017年 LC. All rights reserved.
//

#import "LCBibleTableViewCell.h"

#import "UIView+SDAutoLayout.h"

@interface LCBibleTableViewCell ()

@property (nonatomic,assign) BOOL isNotifications;//

@end

@implementation LCBibleTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self create];
    }
    return self;
}

- (void)create{
    
    UILabel *titleLabel = [UILabel new];
    _titleLabel = titleLabel;
    
    titleLabel.textColor = [UIColor grayColor];
    titleLabel.font = [UIFont systemFontOfSize:19];
    [self.contentView addSubview:titleLabel];
    
    UILabel *contentLabel = [UILabel new];
    _contentLabel = contentLabel;
    contentLabel.textColor = [UIColor lightGrayColor];
    contentLabel.font = [UIFont systemFontOfSize:self.fontSizeTemp];
    contentLabel.textAlignment = NSTextAlignmentLeft;
    contentLabel.backgroundColor = [UIColor clearColor];
    self.contentLabel.numberOfLines = 0;
    
    [self.contentView addSubview:contentLabel];
    
    UIButton *contentButton = [[UIButton alloc] init];
    contentButton.hidden = YES;
    _contentButton = contentButton;
    [contentButton setRadius:5];
    contentButton.backgroundColor = [UIColor redColor];
    contentButton.alpha = 0.8;
    //    [contentButton setTitle:@"2评" forState:(UIControlStateNormal)];
    contentButton.titleLabel.font = [LSZSpecialPackaging setlabelTextFontAdaptiveSize:(10)];
    [contentButton addTarget:self action:@selector(dongTaiPush) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:contentButton];
    
    CGFloat margin = 50;
    
    self.titleLabel.sd_layout
    .leftSpaceToView(self.contentView, 30)
    .topSpaceToView(self.contentView, 20)
    .widthIs(45)
    .heightIs(20);
    
    self.contentLabel.sd_layout
    .leftSpaceToView(self.contentView, 30)
    .rightSpaceToView(self.contentView, 30)
    .topSpaceToView(self.contentView, margin)
    .autoHeightRatio(0);
    
    contentButton.sd_layout
    .rightSpaceToView(self.contentView, 25)
    .topSpaceToView(self.contentView, 20)
    .widthIs(35)
    .heightIs(22);
    
    [self setupAutoHeightWithBottomView:self.contentLabel bottomMargin:margin/2];
    
}

- (void)dongTaiPush
{
    if (self.pushShowComposeVCBlock != nil) {
        self.pushShowComposeVCBlock(self.titleLabel.text, self.contentLabel.text);
    }
}
///跳转到
-(void)receiveNotification:(NSNotification *)notification{
    
    CGFloat titleLabelFont = [notification.userInfo[@"BIBLETEXTFONT"] floatValue];
    self.fontSizeTemp = self.fontSizeTemp + titleLabelFont;
}

-(void)setFontSizeTemp:(CGFloat)fontSizeTemp{
    if (fontSizeTemp > 19+7 || fontSizeTemp < 17) {
        return;
    }
    [[NSUserDefaults standardUserDefaults] setFloat:fontSizeTemp forKey:@"fontSizeTemp"];
}
-(CGFloat)fontSizeTemp{
    if ([[NSUserDefaults standardUserDefaults] floatForKey:@"fontSizeTemp"] == 0) {
        return 19;
    } else {
        return [[NSUserDefaults standardUserDefaults] floatForKey:@"fontSizeTemp"];
    };
}

@end
